import re

from uutil import util_download

if __name__ == "__main__":
    rows = util_download.read_excel_xlsx("D:\\数据核对2 20231120.xlsx", 1)
    i = 0
    for row in rows:
        i = i + 1
        if i == 1:
            continue
        else:
            url = str(row[7].value)
            name = str(row[1].value)
            order_id = str(row[2].value)
            agreement_name = str(row[6].value)
            if url is None:
                print(name + order_id + agreement_name + "为空")
            else:
                print(name + order_id + agreement_name + "处理")

                id___name = "数据核对2//" + order_id + "_" + name
                pattern = '/[-A-Z\(\)0-9a-z_\\u4e00-\\u9fa5]*\.[pdf,rxf]'
                match = re.search(pattern, url)
                if match:
                    search = match.span()
                    # f_new_dir = 'D:/test1/' + url[search[0]:search[1] - 2]
                    old_contract_name = url[int(search[0]) + 1 : int(search[1]) - 2]
                    name___old_contract_name = agreement_name + "_" + old_contract_name
                    type = url[int(search[1]) - 1 :]
                    util_download.download_by_url(
                        url, id___name, name___old_contract_name, type
                    )
